package com.ruoyi.zdgz.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zdgz.domain.Psss;
import com.ruoyi.zdgz.service.IPsssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 主排水监控测点实时数据Controller
 * 
 * @author ruoyi
 * @date 2021-06-21
 */
@RestController
@RequestMapping("/zdgz/psss")
public class PsssController extends BaseController
{
    @Autowired
    private IPsssService psssService;

    /**
     * 查询主排水监控测点实时数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Psss psss)
    {
        startPage();
        List<Psss> list = psssService.selectPsssList(psss);
        return getDataTable(list);
    }

    /**
     * 导出主排水监控测点实时数据列表
     */
    @Log(title = "主排水监控测点实时数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Psss psss)
    {
        List<Psss> list = psssService.selectPsssList(psss);
        ExcelUtil<Psss> util = new ExcelUtil<Psss>(Psss.class);
        return util.exportExcel(list, "主排水监控测点实时数据数据");
    }

    /**
     * 获取主排水监控测点实时数据详细信息
     */
    @GetMapping(value = "/{cdbm}")
    public AjaxResult getInfo(@PathVariable("cdbm") String cdbm)
    {
        return AjaxResult.success(psssService.selectPsssById(cdbm));
    }

    /**
     * 新增主排水监控测点实时数据
     */
    @Log(title = "主排水监控测点实时数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Psss psss)
    {
        return toAjax(psssService.insertPsss(psss));
    }

    /**
     * 修改主排水监控测点实时数据
     */
    @Log(title = "主排水监控测点实时数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Psss psss)
    {
        return toAjax(psssService.updatePsss(psss));
    }

    /**
     * 删除主排水监控测点实时数据
     */
    @Log(title = "主排水监控测点实时数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cdbms}")
    public AjaxResult remove(@PathVariable String[] cdbms)
    {
        return toAjax(psssService.deletePsssByIds(cdbms));
    }
}
